import React, { Component } from 'react';
import { connect } from 'dva';
import { Link, routerRedux } from 'dva/router';
import {  WhiteSpace,
    WingBlank,
    Toast,
    Tabs,
    Flex,
    Icon,
    ListView,
    SegmentedControl,
    Button} from 'antd-mobile';
import NavTopBar from '../../components/NavTopBar/NavTopBar';
import {goods_list,searchOrder} from "../search/GoodsSearch.less";
import MyListView from '../../components/MyListView/MyListView';
import GroupOrderItem from "./groupOrderItem";
import NoLazyImg from '../../components/NoLazyImg/NoLazyImg';
import dianpusvg from "../../assets/img/dianpu.svg";
import rightsvg from "../../assets/img/right.svg";
class GroupSearch extends Component {

    constructor(props) {
        super(props);
        this.state = {
            key:this.props.match.params.data,
            layoutType:true,
        };
        this.AlloyTouch = null;
        console.log(this.state.key)
    }

    refresh = () => {
        return this.props.dispatch({ type: 'shopOpenGroup/groupSearchEFF', obj:{ keyword:this.state.key, pageNo:1 } });
    }

    loadMore = () => {
        return this.props.dispatch({ type: 'shopOpenGroup/groupSearchEFF', obj:{keyword:this.state.key,pageNo:this.props.shopOpenGroup.pageNo+1} });
    }
    getAlloyTouch = (AT) =>{
        this.AlloyTouch = AT;
    };
    render() {
        const {groupSearchList} =this.props.shopOpenGroup;
        const footer = <div style={{padding: 30, textAlign: 'center'}}>
            {this.state.dataLength <= 0 ? <div className="mei"><span style={{position:"absolute",bottom:"0",left:"30%",fontSize:".3rem"}}>没有可查看的订单呦!</span></div> : this.state.isLoading ? '加载中...' : '加载完毕'}
        </div>;
        return (
            <Flex direction="column" className={searchOrder} style={{height:'100%'}}>
                <NavTopBar title="搜索结果" dispatch={this.props.dispatch}/>
                <MyListView
                    style={{marginBottom:'-.2rem',height:'100%',background:"#fff"}}
                    getAlloyTouch={ this.getAlloyTouch }
                    renderFooter={() => footer}
                    refresh={ this.refresh }
                    loadMore={ this.loadMore }
                    hasMore={ this.props.shopOpenGroup.pageNo * this.props.shopOpenGroup.pageSize < this.props.shopOpenGroup.totalRows }
                    // itemWrapperClass={ goods_list }
                    renderItem={(v,i,a)=>{
                        return <GroupOrderItem dataItem={v} refresh={this.refresh} key={i} dispatch={dispatch}></GroupOrderItem>
                    }}
                    data={ groupSearchList }>
                </MyListView>
            </Flex>
        );
    }
}


export default connect(({ shopOpenGroup  }) => ({ shopOpenGroup  }))(GroupSearch);
